using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class SettingPanel: BasePanel<SettingPanel>
{

    public CustomGUIButton btnClose;
    public CustomGUISlider sliderMusic;
    public CustomGUISlider sliderSound;

    public CustomGUIToggle toggleMusic;
    public CustomGUIToggle toggleSound;
    void Start()
    {
        btnClose.clickEvent += ()=>
        {
            HideMe();
            if(SceneManager.GetActiveScene().name == "BeginScene")
            {
                BeginPanel.Instance.ShowMe();

            }

        };
        //监听按钮的变化
        sliderMusic.changeValue += (value) => GameDataMgr.Instance.changeBKValue(value);
        sliderSound.changeValue += (value) => GameDataMgr.Instance.changeSoundValue(value);
        toggleMusic.changeValue += (value) => GameDataMgr.Instance.toggleMusic(value);
        toggleMusic.changeValue += (value) => GameDataMgr.Instance.toggleSFX(value);

        HideMe();
    }

    public void UpdatePanelInfo()
    {
        MusicData musicData = GameDataMgr.Instance.musicData;

        sliderMusic.nowValue = musicData.bkValue;
        sliderSound.nowValue = musicData.soundValue;
        toggleMusic.isSel = musicData.isOpenBK;
        toggleSound.isSel = musicData.isOpenSound;

    }

    public override void ShowMe()
    {
        base.ShowMe();
        UpdatePanelInfo();
    }

    public override void HideMe()
    {
        base.HideMe();
        Time.timeScale = 1.0f;
    }


}
